#ifndef OCTASKRANGE_H_INCLUDED
#define OCTASKRANGE_H_INCLUDED

#include <glib.h>

typedef struct
{
    gpointer    *task_array;
    gulong     ntasks;
}oc_task_range_t;

static inline
void oc_task_range_init ( oc_task_range_t   *task_range,
                            gulong         ntasks  )
{
    //task_dir->task_array = g_new ( oc_task_t, ntasks );
    task_range->task_array = g_slice_alloc ( sizeof ( gpointer ) * ntasks );
    task_range->ntasks = ntasks;
}

static inline
gulong oc_task_range_get_num_tasks ( oc_task_range_t   *task_range )
{
    return task_range->ntasks;
}

static inline
gpointer oc_task_range_set_task ( oc_task_range_t   *task_range,
                                    gulong         i,
                                    gpointer        task    )
{
    return task_range->task_array[i] = task;
}

static inline
gpointer oc_task_range_get_task ( oc_task_range_t   *task_range,
                                    gulong         i )
{
    return task_range->task_array[i];
}

static inline
void oc_task_range_destroy ( oc_task_range_t   *task_range
                        )
{
    //g_free ( task_range->task_array );
    g_slice_free1 ( sizeof ( gpointer ) * task_range->ntasks, task_range->task_array );
}

#endif // OCTASKRANGE_H_INCLUDED
